Object-oriented programming
part 14/26 Β· 94.0 KB total
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
In responsibility-driven design, classes are built around what they need to do and the information they share, in the form of a contract. This is different from data-driven design, where classes are built based on the data they need to store. According to Wirfs-Brock and Wilkerson, the originators of responsibility-driven design, responsibility-driven design is the better approach.cite-ref-wirfs-brock1989-54-0[54]
SOLID and GRASP guidelines
SOLID is a set of five rules for designing good software, created by Michael Feathers:
β’ Single responsibility principle: A class should have only one reason to change.
β’ Open/closed principle: Software entities should be open for extension, but closed for modification.
β’ Liskov substitution principle: Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.
β’ Interface segregation principle: Clients should not be forced to depend upon interfaces that they do not use.
β’ Dependency inversion principle: Depend upon abstractions, not concretes.
GRASP (General Responsibility Assignment Software Patterns) is another set of software design rules, created by Craig Larman, that helps developers assign responsibilities to different parts of a program:cite-ref-55[55]
β’ Creator Principle: allows classes create objects they closely use.
β’ Information Expert Principle: assigns tasks to classes with the needed information.
β’ Low Coupling Principle: reduces class dependencies to improve flexibility and maintainability.
β’ High Cohesion Principle: designing classes with a single, focused responsibility.
β’ Controller Principle: assigns system operations to separate classes that manage flow and interactions.
β’ Polymorphism: allows different classes to be used through a common interface, promoting flexibility and reuse.
β’ Pure Fabrication Principle: create helper classes to improve design, boost cohesion, and reduce coupling.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ